package org.dm.utils
{	
	
	/**
	 * ...
	 * @author Scott
	 */
	public class Iterator
	{
		private var _prev:Iterator = null;
		private var _next:Iterator = null;
		
		private var _key:*;
		private var _data:*;
		
		public function Iterator(data:*,key:* = null)
		{
			this._data = data;		
			this._key = key;
		}
		
		public function get key():* 
		{ 
			return _key; 
		}
		
		public function set key(value:*):void 
		{
			this._key = value;
		}
		
		public function get data():* 
		{ 
			return _data; 
		}
		
		public function set data(value:*):void 
		{
			this._data = value;
		}
		
		public function set next(n:Iterator):void
		{
			if(n!=null)
			{
				n._prev = this;
				n._next = this._next;
			}
			
			if(_next!=null)
			{
				this._next._prev = n;
			}
			
			this._next = n;
		}
		
		public function get next():Iterator
		{
			return _next;
		}
		
		public function set prev(p:Iterator):void
		{
			if(p!=null)
			{
				p._next = this;
				p._prev = this._prev;
			}
			
			if(_prev!=null)
			{
				_prev._next = p;
			}
			
			_prev = p;
		}
		
		public function get prev():Iterator
		{
			return _prev;
		}
		
		public function unlink():void
		{
			if(_prev!=null)
			{
				_prev._next = _next;
			}
			
			if(_next!=null)
			{
				_next._prev = _prev;
			}
			
			_prev = _next = null;
		}
		
		public function release():void
		{
			unlink();
			
			_key = null;			
			_data = null;
		}
	}
}